package com.bearingnavi.android.dialogs;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;

public class Dialog {

	public interface ConfirmHandler { void onConfirm(); }
	
	public static void buildConfirmUndoDialog(Context context, final ConfirmHandler handler) {
		
		buildConfirmDialog(context, "Are you sure you want to clear all?", handler);
	}
	
	public static void buildConfirmDialog(Context context, String message, final ConfirmHandler handler) {
		
		AlertDialog alertDialog = new AlertDialog.Builder(context).create();
		alertDialog.setTitle("Please confirm this operation");
		alertDialog.setMessage(message);
		alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				handler.onConfirm();
				dialog.dismiss();
			}
		});
		alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		});
		
		alertDialog.show();  
		
	}
	
public static AlertDialog buildCustomDialog2(Context context, String title, String message, String confirmBtn, String cancelBtn, final ConfirmHandler handler) {
		
		AlertDialog alertDialog = new AlertDialog.Builder(context).create();
		alertDialog.setTitle(title);
		alertDialog.setMessage(message);
		alertDialog.setButton(confirmBtn, new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				handler.onConfirm();
				dialog.dismiss();
			}
		});
		alertDialog.setButton2(cancelBtn, new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		});
		
		alertDialog.show();  
		return alertDialog;
		
	}
	
	public static void buildAlertDialog(Context context, String title, String messaege) {
		
		AlertDialog alertDialog = new AlertDialog.Builder(context).create();
		alertDialog.setTitle(title);
		alertDialog.setMessage(messaege);
		alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
			
			public void onClick(DialogInterface dialog, int which) {
				dialog.dismiss();
			}
		});
		
		alertDialog.show();  
		
	}
	
}
